home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Dynamic Bu22180742001.psc / Controls / LargeButton3D.ctl < prev    next >
Encoding:
Text File  |  2001-06-16  |  11.8 KB  |  489 lines

  1. VERSION 5.00
  2. Begin VB.UserControl LargeButton3D 
  3.    BackColor       =   &H80000010&
  4.    CanGetFocus     =   0   'False
  5.    ClientHeight    =   2925
  6.    ClientLeft      =   0
  7.    ClientTop       =   0
  8.    ClientWidth     =   4005
  9.    ScaleHeight     =   2925
  10.    ScaleWidth      =   4005
  11.    Begin VB.Timer tmrLeft 
  12.       Enabled         =   0   'False
  13.       Interval        =   1
  14.       Left            =   2880
  15.       Top             =   720
  16.    End
  17.    Begin VB.Timer tmrCheck 
  18.       Enabled         =   0   'False
  19.       Interval        =   1
  20.       Left            =   2400
  21.       Top             =   720
  22.    End
  23.    Begin VB.Line LineDown 
  24.       BorderColor     =   &H80000015&
  25.       Visible         =   0   'False
  26.       X1              =   600
  27.       X2              =   0
  28.       Y1              =   600
  29.       Y2              =   600
  30.    End
  31.    Begin VB.Line LineRight 
  32.       BorderColor     =   &H80000015&
  33.       Visible         =   0   'False
  34.       X1              =   600
  35.       X2              =   600
  36.       Y1              =   0
  37.       Y2              =   600
  38.    End
  39.    Begin VB.Line LineUp 
  40.       BorderColor     =   &H80000014&
  41.       Visible         =   0   'False
  42.       X1              =   0
  43.       X2              =   600
  44.       Y1              =   0
  45.       Y2              =   0
  46.    End
  47.    Begin VB.Line LineLeft 
  48.       BorderColor     =   &H80000014&
  49.       Visible         =   0   'False
  50.       X1              =   0
  51.       X2              =   0
  52.       Y1              =   0
  53.       Y2              =   600
  54.    End
  55.    Begin VB.Image imgPIC 
  56.       Height          =   495
  57.       Left            =   2400
  58.       Top             =   120
  59.       Width           =   495
  60.    End
  61.    Begin VB.Image imgEPIC 
  62.       Height          =   495
  63.       Left            =   2400
  64.       Top             =   1320
  65.       Visible         =   0   'False
  66.       Width           =   1215
  67.    End
  68.    Begin VB.Image imgDPIC 
  69.       Height          =   495
  70.       Left            =   2400
  71.       Top             =   1800
  72.       Visible         =   0   'False
  73.       Width           =   1215
  74.    End
  75. End
  76. Attribute VB_Name = "LargeButton3D"
  77. Attribute VB_GlobalNameSpace = False
  78. Attribute VB_Creatable = True
  79. Attribute VB_PredeclaredId = False
  80. Attribute VB_Exposed = False
  81. Option Explicit
  82.  
  83. 'Local variables for the properties
  84. Private booIsDown                   As Boolean
  85. Private booStayUp                   As Boolean
  86. Private booIsPopUp                  As Boolean
  87.  
  88. 'Variables
  89. Public booIsClicked                 As Boolean
  90.  
  91. 'Objects
  92. Public ctl                          As Control
  93.  
  94. 'Events
  95. Event Click()
  96.  
  97. '***************************************************************************
  98. 'Properties
  99. '***************************************************************************
  100.  
  101. Public Property Get IsDown() As Boolean
  102.     IsDown = booIsDown
  103. End Property
  104.  
  105. Public Property Let IsDown(booValue As Boolean)
  106.     booIsDown = booValue
  107.     PropertyChanged "IsDown"
  108. End Property
  109.  
  110. Public Property Get IsPopup() As Boolean
  111.     IsPopup = booIsPopUp
  112. End Property
  113.  
  114. Public Property Let IsPopup(booValue As Boolean)
  115.     booIsPopUp = booValue
  116.     PropertyChanged "IsPopup"
  117. End Property
  118.  
  119. Public Property Get StayUp() As Boolean
  120.     StayUp = booStayUp
  121. End Property
  122.  
  123. Public Property Let StayUp(ByVal booValue As Boolean)
  124.     'If Ambient.UserMode Then Err.Raise 393
  125.     booStayUp = booValue
  126.     PropertyChanged "StayUp"
  127.     tmrCheck.Enabled = Not booValue
  128.     
  129.     If booValue Then
  130.      PopUp
  131.     Else
  132.      PopDown
  133.     End If
  134. End Property
  135.  
  136. Public Property Get Stretch() As Boolean
  137.     Stretch = imgPIC.Stretch
  138. End Property
  139.  
  140. Public Property Let Stretch(ByVal booStretch As Boolean)
  141.     imgPIC.Stretch() = booStretch
  142.     PropertyChanged "Stretch"
  143.     
  144.     UserControl_Resize
  145.     Refresh
  146. End Property
  147.  
  148. Public Property Get Enabled() As Boolean
  149. Attribute Enabled.VB_UserMemId = -514
  150.     Enabled = UserControl.Enabled
  151. End Property
  152.  
  153. Public Property Let Enabled(ByVal booValue As Boolean)
  154.     UserControl.Enabled() = booValue
  155.     PropertyChanged "Enabled"
  156.     
  157.     If UserControl.Enabled = False Then
  158.         imgPIC.Picture = imgDPIC.Picture
  159.     Else
  160.         imgPIC.Picture = imgEPIC.Picture
  161.     End If
  162.     
  163.     UserControl_Resize
  164.     Refresh
  165. End Property
  166.  
  167. Public Property Get Picture() As Picture
  168.     Set Picture = imgEPIC.Picture
  169. End Property
  170.  
  171. Public Property Set Picture(ByVal picValue As Picture)
  172.     Set imgEPIC.Picture = picValue
  173.     PropertyChanged "Picture"
  174.     If Enabled Then
  175.         imgPIC.Picture = imgEPIC.Picture
  176.     Else
  177.         imgPIC.Picture = imgDPIC.Picture
  178.     End If
  179.  
  180.     UserControl_Resize
  181.     Refresh
  182. End Property
  183. '
  184. Public Property Get DisabledPicture() As Picture
  185.     Set DisabledPicture = imgDPIC.Picture
  186. End Property
  187.  
  188. Public Property Set DisabledPicture(ByVal picValue As Picture)
  189.     Set imgDPIC.Picture = picValue
  190.     PropertyChanged "DisabledPicture"
  191.     
  192.     UserControl_Resize
  193.     Refresh
  194. End Property
  195.  
  196. Public Property Get hwnd() As Long
  197.     hwnd = UserControl.hwnd
  198. End Property
  199.  
  200. '***************************************************************************
  201. 'Procedures
  202. '***************************************************************************
  203. Public Sub Refresh()
  204.     UserControl.Refresh
  205. End Sub
  206.  
  207. Public Sub PopPress()
  208.     IsDown = False
  209.     
  210.     'Doe de acties met de lijnen
  211.     With LineDown
  212.         .Visible = True
  213.         .X1 = 0
  214.         .X2 = 600
  215.         .Y1 = 0
  216.         .Y2 = 0
  217.     End With
  218.     With LineUp
  219.         .Visible = True
  220.         .X1 = 600
  221.         .X2 = 0
  222.         .Y1 = 600
  223.         .Y2 = 600
  224.     End With
  225.     With LineLeft
  226.         .Visible = True
  227.         .X1 = 600
  228.         .X2 = 600
  229.         .Y1 = 0
  230.         .Y2 = 600
  231.     End With
  232.     With LineRight
  233.         .Visible = True
  234.         .X1 = 0
  235.         .X2 = 0
  236.         .Y1 = 0
  237.         .Y2 = 600
  238.     End With
  239. '    imgPIC.Left = imgPIC.Left + 20
  240. '    imgPIC.Top = imgPIC.Top + 20
  241. End Sub
  242.  
  243. Public Sub PopDown()
  244.     If StayUp = True Then Exit Sub
  245.     If IsDown Then Exit Sub
  246.     IsDown = True
  247.     
  248. '    If imgPIC.Left <> UserControl.ScaleWidth / 2 - imgPIC.Width / 2 Then _
  249. '     imgPIC.Left = UserControl.ScaleWidth / 2 - imgPIC.Width / 2
  250. '    If imgPIC.Top <> UserControl.ScaleHeight / 2 - imgPIC.Height / 2 Then _
  251. '     imgPIC.Top = UserControl.ScaleHeight / 2 - imgPIC.Height / 2
  252.      
  253.     'Doe de acties met de lijnen
  254.     With LineDown
  255.         .Visible = False
  256.         .X1 = 0
  257.         .X2 = 600
  258.         .Y1 = 0
  259.         .Y2 = 0
  260.     End With
  261.     With LineUp
  262.         .Visible = False
  263.         .X1 = 600
  264.         .X2 = 0
  265.         .Y1 = 600
  266.         .Y2 = 600
  267.     End With
  268.     With LineLeft
  269.         .Visible = False
  270.         .X1 = 600
  271.         .X2 = 600
  272.         .Y1 = 0
  273.         .Y2 = 600
  274.     End With
  275.     With LineRight
  276.         .Visible = False
  277.         .X1 = 0
  278.         .X2 = 0
  279.         .Y1 = 0
  280.         .Y2 = 600
  281.     End With
  282. End Sub
  283.  
  284. Public Sub PopUp()
  285.     UserControl_Resize
  286.     IsDown = False
  287.  
  288.     'Doe de acties met de lijnen
  289.     With LineDown
  290.         .Visible = True
  291.         .X1 = 600
  292.         .X2 = 0
  293.         .Y1 = 600
  294.         .Y2 = 600
  295.     End With
  296.     With LineUp
  297.         .Visible = True
  298.         .X1 = 0
  299.         .X2 = 600
  300.         .Y1 = 0
  301.         .Y2 = 0
  302.     End With
  303.     With LineLeft
  304.         .Visible = True
  305.         .X1 = 0
  306.         .X2 = 0
  307.         .Y1 = 0
  308.         .Y2 = 600
  309.     End With
  310.     With LineRight
  311.         .Visible = True
  312.         .X1 = 600
  313.         .X2 = 600
  314.         .Y1 = 0
  315.         .Y2 = 600
  316.     End With
  317. End Sub
  318.  
  319. Public Sub CheckButton(hwd As Long, doit As String)
  320.     If doit <> "vas123" Then
  321.         MsgBox "CheckButton is an event that only the control can use. Please remove it from the project code.", vbCritical, "Error..."
  322.         Exit Sub
  323.     End If
  324.  
  325.     If GetActiveWindow() <> GetParentHwnd Then
  326.         PopDown
  327.         Exit Sub
  328.     End If
  329.     
  330.     If hwnd = hwd Then
  331.         If StayUp = True Then
  332.             tmrCheck.Enabled = True
  333.             Exit Sub
  334.         End If
  335. '        For Each ctl In UserControl.ParentControls
  336. '            If ctl.hwnd = hwnd Then
  337. '                ctl.ZOrder
  338. '            End If
  339. '        Next ctl
  340.         PopUp
  341.         If booIsClicked = True Then PopPress
  342.         tmrLeft.Enabled = True
  343.         tmrCheck.Enabled = False
  344.         Exit Sub
  345.     Else
  346.         PopDown
  347.     End If
  348.     tmrCheck.Enabled = True
  349. End Sub
  350.  
  351. '***************************************************************************
  352. 'Control events
  353. '***************************************************************************
  354. Private Sub imgPIC_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  355.     If Button = vbLeftButton Then PopPress
  356.     booIsClicked = True
  357. End Sub
  358.  
  359. Private Sub imgPIC_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  360.     Dim curHwnd As Long
  361.     Dim pt As POINTAPI
  362.     
  363.     GetCursorPos pt
  364.     
  365.     curHwnd = WindowFromPoint(pt.X, pt.Y)
  366.     
  367.     If curHwnd <> hwnd Then
  368.         booIsClicked = False
  369.         PopDown
  370.         CheckButton hwnd, "vas123"
  371.         Exit Sub
  372.     Else
  373.         booIsClicked = False
  374.         PopUp
  375.         If Button = vbLeftButton Then RaiseEvent Click
  376.     End If
  377. End Sub
  378.  
  379. Private Function GetParentHwnd() As Long
  380.     GetParentHwnd = UserControl.Parent.ParentHwnd
  381. End Function
  382.  
  383. Private Sub tmrCheck_Timer()
  384. On Error Resume Next
  385.     Dim pt As POINTAPI
  386.  
  387.     If GetActiveWindow() <> GetParentHwnd Then Exit Sub
  388.     GetCursorPos pt
  389.     new_HWND = WindowFromPoint(pt.X, pt.Y)
  390.     old_HWND = new_HWND
  391.     tmrCheck.Enabled = False
  392.     If new_HWND <> Me.hwnd Then PopDown
  393.     CheckButton new_HWND, "vas123"
  394. End Sub
  395.  
  396. Private Sub tmrLeft_Timer()
  397. On Error Resume Next
  398.     Dim pt As POINTAPI
  399.  
  400.     GetCursorPos pt
  401.     new_HWND = WindowFromPoint(pt.X, pt.Y)
  402.     If new_HWND <> hwnd Then
  403.         If booIsClicked Then PopUp Else PopDown
  404.         IsPopup = False
  405.         IsDown = True
  406.         tmrLeft.Enabled = False
  407.         tmrCheck.Enabled = True
  408.     End If
  409. End Sub
  410.  
  411. Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  412.     If Button = vbLeftButton Then PopPress
  413.     booIsClicked = True
  414. End Sub
  415.  
  416. Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
  417.     Dim curHwnd As Long
  418.     Dim pt As POINTAPI
  419.     
  420.     GetCursorPos pt
  421.     curHwnd = WindowFromPoint(pt.X, pt.Y)
  422.     If curHwnd <> hwnd Then
  423.         booIsClicked = False
  424.         PopDown
  425.         CheckButton hwnd, "vas123"
  426.         Exit Sub
  427.     Else
  428.         booIsClicked = False
  429.         PopUp
  430.         If Button = vbLeftButton Then RaiseEvent Click
  431.     End If
  432. End Sub
  433.  
  434. Private Sub UserControl_Resize()
  435.  
  436.     UserControl.Width = 610
  437.     UserControl.Height = 610
  438.  
  439.     imgPIC.Left = 480
  440.     imgPIC.Top = 120
  441.     
  442.     'Doe de acties met de lijnen
  443.     With LineDown
  444.         .X1 = 600
  445.         .X2 = 0
  446.         .Y1 = 600
  447.         .Y2 = 600
  448.     End With
  449.     With LineUp
  450.         .X1 = 0
  451.         .X2 = 600
  452.         .Y1 = 0
  453.         .Y2 = 0
  454.     End With
  455.     With LineLeft
  456.         .X1 = 0
  457.         .X2 = 0
  458.         .Y1 = 0
  459.         .Y2 = 600
  460.     End With
  461.     With LineRight
  462.         .X1 = 600
  463.         .X2 = 600
  464.         .Y1 = 0
  465.         .Y2 = 600
  466.     End With
  467.     
  468.     LineDown.Visible = True
  469.     LineUp.Visible = True
  470.     LineLeft.Visible = True
  471.     LineRight.Visible = True
  472.     
  473.     If imgPIC.Stretch = True Then
  474.         imgPIC.Top = 0
  475.         imgPIC.Left = 0
  476.         imgPIC.Height = UserControl.ScaleHeight
  477.         imgPIC.Width = ScaleWidth
  478.     Else
  479.         If imgPIC.Left <> UserControl.ScaleWidth / 2 - imgPIC.Width / 2 Then imgPIC.Left = UserControl.ScaleWidth / 2 - imgPIC.Width / 2
  480.         If imgPIC.Top <> UserControl.ScaleHeight / 2 - imgPIC.Height / 2 Then imgPIC.Top = UserControl.ScaleHeight / 2 - imgPIC.Height / 2
  481.     End If
  482.  
  483. End Sub
  484.  
  485. Private Sub UserControl_Click()
  486.     RaiseEvent Click
  487. End Sub
  488.  
  489.